

import java.util.*;
public class Solution {  //逆波兰表达式
    public int evalRPN(String[] tokens) {
        Stack<Integer> stack = new Stack<>();
        for(String x:tokens){
            if(!isOperation(x)){
                stack.push(Integer.valueOf(x));
            }else{
                int k = stack.pop();
                int y =stack.pop();
                char ch=x.charAt(0);
                switch(ch){
                    case '+': stack.push(y+k);break;
                    case '-': stack.push(y-k);break;
                    case '*': stack.push(y*k);break;
                    case '/': stack.push(y/k);break;
                    default:break;
                }

            }
        }
        return stack.pop();
    }




    public boolean isOperation(String str){
        if(str.equals("+")||str.equals("-")||str.equals("*")||str.equals("/")){
            return true;
        }
        return false;
    }

}